import request from '@/utlis/request'
// 获取订单信息
export const createOrder = () => {
  return request('/member/order/pre', 'get')
}
// 删除地址
export const deleteAddress = (id) => {
  return request(`/member/address/${id}`, 'delete')
}
// 添加地址
export const addAddress = (form) => {
  return request('/member/address', 'post', form)
}
// 修改地址
export const editAddress = (form) => {
  return request(`/member/address/${form.id}`, 'put', form)
}
// 提交订单
export const submitOrder = (obj) => {
  return request('/member/order', 'post', obj)
}
// 查询订单详情
// orderId 订单ID
export const findOrderDetail = (orderId) => {
  return request('/member/order/' + orderId, 'get')
}
// 获取订单列表
// page页码 pageSize每页条数 orderState订单状态
export const findOrderList = ({ page = 1, pageSize = 10, orderState = 0 }) => {
  return request('/member/order', 'get', { page, pageSize, orderState })
}
/**
 * 取消订单
 * @param {String} orderId - 订单ID
 * @param {String} cancelReason - 取消原因
 * @returns Promise
 */
export const cancelOrder = (orderId, cancelReason) => {
  return request(`/member/order/${orderId}/cancel`, 'put', { cancelReason })
}
/**
 * 删除订单
 * @param {String} orderId - 订单ID
 * @returns Promise
 */
export const deleteOrder = (orderId) => {
  return request('/member/order', 'DELETE', { ids: [orderId] })
}
/**
 * 确认收货
 * @param {String} orderId - 订单ID
 * @returns Promise
 */
export const cofirmOrder = (orderId) => {
  return request(`/member/order/${orderId}/receipt`, 'put')
}
/**
 * 查看物流
 * @param {String} id - 订单ID
 * @returns
 */
export const logisticsOrder = (id) => {
  return request(`/member/order/${id}/logistics`, 'get')
}
/**
 * 获取再次购买的订单结算信息
 * @param {String} id - 订单ID
 * @returns
 */
export const findOrderRepurchase = (id) => {
  return request(`/member/order/repurchase/${id}`, 'get')
}
